
package net.uman.framework.io;

import net.uman.framework.io.IFileManager;
import net.uman.framework.io.LocalFileManager;
import net.uman.framework.modules.utils.ApplicationPropertiesHelper;
/**
 * 
 * @author lihengjun
 *
 */
public class FileManagerFactory {
	private static IFileManager fileManager = null;
				
  public synchronized static IFileManager getFileManager() {
  	if (fileManager == null) {
    	String root = System.getProperty("UMAN_HOME");
    	System.out.println("File root:"+root);
    	fileManager = new LocalFileManager(root);
    }
    
    return fileManager;
  }
  
  
  private static IFileManager tempFileManager = null;
	private static IFileManager imgFileManager = null;
	private static IFileManager attachmentFileManager = null;
	private static IFileManager contractDocManager = null;
				
public synchronized static IFileManager getTempFileManager() {
	if (tempFileManager == null) {
	  tempFileManager = new LocalFileManager(ApplicationPropertiesHelper.getTempFilePath());
  }
  
  return tempFileManager;
}

public synchronized static IFileManager getImgFileManager() {
    if (imgFileManager == null) {
        imgFileManager = new LocalFileManager(ApplicationPropertiesHelper.getImgFilePath());
    }
    
    return imgFileManager;
}

public synchronized static IFileManager getAttDocManager() {
    if (attachmentFileManager == null) {
        attachmentFileManager = new LocalFileManager(ApplicationPropertiesHelper.getAttDocPath());
    }
    
    return attachmentFileManager;
}

public synchronized static IFileManager getContractFileManager() {
    if (contractDocManager == null) {
        contractDocManager = new LocalFileManager(ApplicationPropertiesHelper.getContractFilePath());
    }
    
    return contractDocManager;
}
}
